
module.exports = async (ctx, next) => {
    const {studentShortId,imgUrl,time} = ctx.request.body;
    // console.log("policies .body", ctx.request.body);
    if(studentShortId){
        const regex = new RegExp(studentShortId + "$");
        const students = await strapi.services.student.fetchAll({id:{$regex:regex }});
        if(students.length===0){
            return ctx.notFound();
        }
        // console.log("student", students[0].id,students[0].name,);
        ctx.request.body ={
            time,
            imgUrl,
            student: students[0].id,
        }
    }
    await next();
};
